<template>
	<div>
	    <div class="crumbs">
	        <el-breadcrumb separator="/">
	            <el-breadcrumb-item>
	                <i class="el-icon-lx-cascades"></i> 优秀部门评选
	            </el-breadcrumb-item>
	        </el-breadcrumb>
	    </div>
		
		<div class="block">
		  <span class="demonstration">选择部门：</span>
		  <el-cascader
		    ref="myCascader"
		    v-model="value"
		    :options="options"
		    @change="handleChange"></el-cascader>
		</div>
		
		<div class="el-table__empty-block">
			<span class="title-name">例会：</span>
			<v-rate v-model="valueA1"
			show-text
			text-type="number"
			text-template="{value}分"
			:size="23" :allow-half="true" :max="10"></v-rate>
		</div>	
		<div class="el-table__empty-block">
			<span class="title-name">值班：</span>
			<v-rate v-model="valueA2"
			show-text
			text-type="number"
			text-template="{value}分"
			:size="23" :allow-half="true" :max="10"></v-rate>
		</div>	
		<div class="el-table__empty-block">
			<span class="title-name">工作计划总结：</span>
			<v-rate v-model="valueA3"
			show-text
			text-type="number"
			text-template="{value}分"
			:size="23" :allow-half="true" :max="10"></v-rate>
		</div>	
		<div class="el-table__empty-block">
			<span class="title-name">特色建设：</span>
			<v-rate v-model="valueA4"
			show-text
			text-type="number"
			text-template="{value}分"
			:size="23" :allow-half="true" :max="10"></v-rate>
		</div>	
		<div class="el-table__empty-block">
			<span class="title-name">物品管理：</span>
			<v-rate v-model="valueA5"
			show-text
			text-type="number"
			text-template="{value}分"
			:size="23" :allow-half="true" :max="10"></v-rate>
		</div>	
		<div class="el-table__empty-block">
			<span class="title-name">精神风貌：</span>
			<v-rate v-model="valueA6"
			show-text
			text-type="number"
			text-template="{value}分"
			:size="23" :allow-half="true" :max="10"></v-rate>
		</div>	
		<div class="el-table__empty-block">
			<span class="title-name">工作关注程度：</span>
			<v-rate v-model="valueA7"
			show-text
			text-type="number"
			text-template="{value}分"
			:size="23" :allow-half="true" :max="10"></v-rate>
		</div>	
		<div class="el-table__empty-block">
			<span class="title-name">财务：</span>
			<v-rate v-model="valueA8"
			show-text
			text-type="number"
			text-template="{value}分"
			:size="23" :allow-half="true" :max="10"></v-rate>
		</div>	
		<div class="el-table__empty-block">
			<span class="title-name">材料报送考核：</span>
			<v-rate v-model="valueA9"
			show-text
			text-type="number"
			text-template="{value}分"
			:size="23" :allow-half="true" :max="10"></v-rate>
		</div>
		<div class="el-table__empty-block">
			<span class="title-name">评价考核：</span>
			<v-rate v-model="valueA10"
			show-text
			text-type="number"
			text-template="{value}分"
			:size="23" :allow-half="true" :max="10"></v-rate>
		</div>
		<div class="el-table__empty-block">
			 <el-button type="primary" @click="commitEdit()">提交</el-button>
		</div>	
		
		
		
		
		
	</div>
</template>

<script>
import rate from "../common/Rate.vue"
import '../../styles/less/index.less'
export default{
	data(){
		return{
			rate,
			valueA1: 0,
			valueA2: 0,
			valueA3: 0,
			valueA4: 0,
			valueA5: 0,
			valueA6: 0,
			valueA7: 0,
			valueA8: 0,
			valueA9: 0,
			valueA10: 0,
			value: [],
			options: [{
			  value: '0',
			  label: '宣传部'
			  },
			  {
			  value: '1',
			  label: '组织部'
			  },
		      {
			  value: '2',
			  label: '外联部'
			  },
			  {
			   value: '3',
			   label: '秘书处'
			  },
			  {
			    value: '4',
			    label: '志愿站'
			   },
			   {
			     value: '5',
			     label: '办公室'
			    },
				{
				  value: '6',
				  label: '文体部'
				 },
				 {
				  value: '7',
				  label: '学习部'
				 },
				 {
				  value: '8',
				  label: '师友电脑维修部'
				 },
				 {
				  value: '9',
				  label: '自律部'
				 },
				 {
				  value: '10',
				  label: '网络技术部'
				 },
				 {
				  value: '11',
				  label: '辩论队'
			 }]
		}
	},
	methods:{
		// 提交评分
		async commitEdit(){
			console.log(this.value[0]);
			console.log((parseFloat(this.valueA1)+parseFloat(this.valueA2)+parseFloat(this.valueA3)+parseFloat(this.valueA4)+parseFloat(this.valueA5)+parseFloat(this.valueA6)+parseFloat(this.valueA7)+parseFloat(this.valueA8)+parseFloat(this.valueA9)+parseFloat(this.valueA10))/parseInt('10'));
			
			console.log(this.$refs.myCascader.getCheckedNodes()[0].pathLabels[0]);
			
		
			let res = await this.$Http.addSelection(
				{
					markItem : 1,
					judgedId : this.value[0],
					judgedName : this.$refs.myCascader.getCheckedNodes()[0].pathLabels[0],
					judgeId : '201441404266',
					judgeName : 'justin',
					departmentName  : this.$refs.myCascader.getCheckedNodes()[0].pathLabels[0],
					totalScore : (parseFloat(this.valueA1)+parseFloat(this.valueA2)+parseFloat(this.valueA3)+parseFloat(this.valueA4)+parseFloat(this.valueA5)+parseFloat(this.valueA6)+parseFloat(this.valueA7)+parseFloat(this.valueA8)+parseFloat(this.valueA9)+parseFloat(this.valueA10))/parseInt('10')
				},
			    true
			);
			console.log(res);
			console.log(res.status);
			if (res.status == 0){
				this.$message.success(`新增成功`);
			}else{
				this.$message.error(res.msg);
			}
		}
	},
	components:{  /* 前面的组件名称不能和HTML标签一样*/
    'v-rate':rate    //挂载RATE组件
  }
}

</script>
